<?php

namespace app\mobile\controller;

use app\common\controller\Frontend;
use think\Db;
use think\Request;

class Hangyexinxi extends Frontend
{

    protected $noNeedLogin = '*';
    protected $noNeedRight = '*';
    protected $layout = '';

    public function index()
    {
		$banner=Db::name('banner')->where([
			'type_data'=>1,
			'bannertype_id'=>2
		])->find();
		$this->assign('banner',$banner);
		
		$hangyexinxitype=Db::name('hangyexinxitype')->where([
			'show_switch'=>1,
		])->order('weigh desc')->select();
		foreach($hangyexinxitype as $k=>$v){
			$hangyexinxitype[$k]['list']=Db::name('hangyexinxi')->where(['type_id'=>$v['id']])->order('weigh desc')->select();
		}
		$all_hangyexinxi=Db::name('hangyexinxi')->order('weigh desc')->select();
		$this->assign('hangyexinxitype',$hangyexinxitype);
		$this->assign('all_hangyexinxi',$all_hangyexinxi);
        return $this->view->fetch();
    }
	
	public function detail(Request $request){
		$id=$request->param('id/d',0);
		$rs=Db::name('hangyexinxi')->where(['id'=>$id])->order('weigh desc')->find();
		if(is_null($rs)){
			$this->error('内容不存在');
		}
		Db::name('hangyexinxi')->where('id',$id)->setInc('views');
		$this->assign('rs',$rs);
		return $this->view->fetch();
	}

}
